import Vue from 'vue'
import VueRouter from 'vue-router'
import HomeView from '../views/HomeView.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: HomeView,
    redirect: '/index',  // 重定向:重新指向其它path,会改变网址
    children: [
      // 子路由中的path前面不要加 /
      {
        path: 'course',
        component: () => import('@/views/course/course.vue'),
      },
      {
        path: 'index',
        component: () => import('@/views/index/index.vue'),
      },
      {
        path: 'exercise',
        component: () => import('@/views/exercise/exercise.vue'),
      },
      {
        path: 'record',
        component: () => import('@/views/record/record.vue'),
      },
      {
        path: 'my',
        component: () => import('@/views/my/my.vue'),
      }

    ],
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  }, {
    path: '/login',
    component: () => import('@/views/my/login.vue'),
  }, {
    path: '/set',
    component: () => import('@/views/my/set.vue'),
  }, {
    path: '/setPassword',
    component: () => import('@/views/my/setPassword.vue'),
  }, {
    path: '/mycode',
    component: () => import('@/views/my/mycode.vue'),
  }, {
    path: '/lecturer',
    component: () => import('@/views/index/lecturer.vue'),
  }, {
    path: '/search',
    component: () => import('@/views/course/search.vue'),
  }, {
    path: '/courses',
    component: () => import('@/views/index/course.vue'),
  }

]

const router = new VueRouter({
  routes
})

export default router
